package com.yhj.reggie.mapper;

import com.yhj.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface  SetmealMapper {

    //根据类品id找数量
    @Select("select count(*) from setmeal where category_id=#{categoryId} and is_deleted=0")
    Integer countByCid(Long categoryId);

    //添加套餐
    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    Integer save(Setmeal setmeal);

    //分页查询套餐数据,模糊查名称
    List<Setmeal> findAll(@Param("name") String name);

    //查询指定id列表数据中含有启用套餐数据的个数
    Integer countById(@Param("ids") List<Long> ids);

    //删除套餐(伪删除)
    Integer deleteByIds(@Param("ids") List<Long> ids, @Param("updateUser") Long updateUser,
                        @Param("updateTime") LocalDateTime updateTime);
}
